<?php
/** 
*
* @package phpBB3
* @version $Id: donate.php 87 2007-07-04 04:43:06Z highwayoflife $
* @copyright (c) 2007 Star Trek Guide Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

$mod = 'donate';
$version = '1.0.B1';

// Start session management
$user->session_begin();
$auth->acl($user->data);

if ($user->data['is_bot'])
{
	redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}

$sql = 'SELECT style_id FROM ' . STYLES_TABLE . " WHERE style_name = 'prosilver'";
$db->sql_query($sql, 2678400);
$style = $db->sql_fetchfield('style_id');

$user->setup('mods/permissions_starbase', $style);

// check to see if the MOD is installed. If not, install it.
if (!isset($config[$mod . '_version']))
{	
	install_mod($mod, $version);
}
else if (version_compare($config[$mod . '_version'], $version, '<'))
{
	// the current version is older... update it.
	update_mod($mod, $version);
}

$s_hidden_fields = build_hidden_fields(array(
	'cmd'			=> '_xclick',
	'business'		=> $config['board_contact'],
	'item_name'		=> $config['sitename'],
	'item_number'	=> 'uid_' . $user->data['user_id'] . '_' . time(),
	'no_shipping'	=> 1,
	'return'		=> append_sid(generate_board_url(true) . '/starbase/thanks.' . $phpEx, 'ref=' . base64_encode('paypal')),
	'cancel_return'	=> append_sid(generate_board_url(true) . '/starbase/thanks.' . $phpEx, 'cancel=1'),
	'tax'			=> '0',
	'page_style'	=> 'prosilver',
	'bn'			=> 'PP-DonationsBF',
));

$s_currency_options = '';
foreach ($user->lang['currency_code'] as $key => $value)
{
	$selected = ($key == $user->lang['DEFAULT_CURRENCY_CODE']) ? ' selected="selected"' : '';
	$s_currency_options .= '<option value="' . $key . '"' . $selected . '>' . $value . ' (' . $key . ")</option>\n";
}

$s_country_options = '';
foreach ($user->lang['country_options'] as $key => $value)
{
	$selected = ($key == $user->lang['DEFAULT_COUNTRY']) ? ' selected="selected"' : '';
	$s_country_options .= '<option value="' . $key . '"' . $selected . '>' . $value . "</option>\n";
}

$template->assign_vars(array(
	'L_DONATE_TO_SITENAME'	=> sprintf($user->lang['DONATE_TO_SITENAME'], $config['sitename']),
	'U_BOARD_CONTACT'		=> 'mailto:' . $config['board_contact'],
	'S_CURRENCY_OPTIONS'	=> $s_currency_options,
	'S_COUNTRY_OPTIONS'		=> $s_country_options,
	'S_DONATE_FIELDS'		=> $s_hidden_fields,
	'S_DONATE_ACTION'		=> 'https://www.paypal.com/cgi-bin/webscr',
));


// Output page
page_header(sprintf($user->lang['DONATE_TO_SITENAME'], $config['sitename']));

$template->set_filenames(array(
	'body' => 'donate_body.html')
);

page_footer();

?>